package com.itheima.reggie.sercice.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.reggie.dao.DishDao;
import com.itheima.reggie.domain.Dish;
import com.itheima.reggie.sercice.DishFlavorService;
import com.itheima.reggie.sercice.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DishServiceImpl extends ServiceImpl<DishDao, Dish> implements DishService {

    @Autowired
    private DishFlavorService dishFlavorService;

   /* @Override
    @Transactional
    public void saveWithDishFlavor(DishDto dishDto) {
        this.save(dishDto);
        List<DishFlavor> flavors = dishDto.getFlavors();
        if (flavors != null && flavors.size() > 0) {
            Long dishId = dishDto.getId();
            for (DishFlavor flavor : flavors) {
                flavor.setDishId(dishId);
                dishFlavorService.save(flavor);
            }

        }

    }*/

/*
    @Override
    @Transactional
    public DishDto getWithDishFlavor(Long id) {
        //从dish表穿菜品的基本信息
        Dish dish = this.getById(id);
        DishDto dishDto = new DishDto();
        BeanUtils.copyProperties(dish,dishDto);

        //从dishflavor表查询菜品的口味信息
        LambdaQueryWrapper<DishFlavor> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DishFlavor::getDishId,dish.getId());
        List<DishFlavor> list = dishFlavorService.list(wrapper);
        dishDto.setFlavors(list);

        return dishDto;

    }
*/

   /* @Override
    public void updateWithDishFlavor(DishDto dishDto) {
        this.getById(dishDto);
    }*/
}
